#include <amxmodx>
#include <fun>
#include <rpgx>

new upgrade_id;

public plugin_init()
	register_plugin("FrostPistol RPGx Upgrade", "2.0", "roflmao456");

public RPGx_OnPluginReady()
	upgrade_id = RPGx_MakeUpgrade("FrostPistol", 10, 20, 15);

public RPGx_OnPlayerDeath(victim, killer, headshot)
	remove_task(victim);

public RPGx_OnPlayerHurt(victim, attacker, damage, weapon){
	if(get_user_health(victim) > damage){
		new level = RPGx_GetUpgradeLevel(attacker, upgrade_id);
		if(level && (weapon == CSW_GLOCK18 || weapon == CSW_USP || weapon == CSW_P228 || weapon == CSW_DEAGLE || weapon == CSW_FIVESEVEN || weapon == CSW_ELITE)){
			remove_task(victim);
			RPGx_Freeze(victim);
			set_task(float(level) / 10.0, "Defrost", victim);
			}
		} else {
		set_user_rendering(victim);
		}
	}

public Defrost(id){
	RPGx_Freeze(id, false);
	remove_task(id);
	}